﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Markup;
using System.Collections;
using System.Text;
using System.Diagnostics; 

namespace MyPCTagging
{
    [ContentProperty("SubComponents")]//声明在xaml文件中显示的内容属性?

    public class Node: INotifyPropertyChanged //继承自INotifyPropertyChanged用于双向绑定数据
    {   
        //属性
        public int NodeID { set; get; }
        public string NodeName { set; get; }
        public string Description { get; set; }
        public string Icon { get; set; }
        public bool IsGroup { set; get; }

        //全局变量
        public Collection<Node> Subcomponents {set;get;}
        private bool? _shouldInstall;//是否被选中
        
        //是否有子节点
        public bool HasSubcomponents
        {
            get
            {
                return Subcomponents.Count>0;
            }
        }

        //是否允许Node安置       
        public bool? ShouldInstall 
        {
            get
            {
                return _shouldInstall;
            }
            set
            {
                if (value != _shouldInstall)
                    _shouldInstall = value;
                OnPropertyChanged("ShouldInstall");
            }
        }

        //构造函数
        public Node()
        {
            Subcomponents = new Collection<Node>();
            _shouldInstall = false;
        }
      
        //事件委托
        public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (null != handler)
                handler.Invoke(this,new  PropertyChangedEventArgs(propertyName));
        }
    }
}//ns
